#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a, b;
        cin>>a>>b;
        if(0 <= a <= 600000&&0<=b<=6000000){
            if(a>b){
                int temp=a;
                a=b;
                b=temp;
            }
            int sum=0;
            for(int j=1;j<a;j++){
                if(a%j==0){
                    sum+=j;
                }
            }
            if(sum==b){
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }else{
            return 0;
        }
    }
    
}